//
//  LoginViewController.swift
//  groupTaskTwo
//
//  Created by 向银泉 on 16/11/3.
//  Copyright © 2016年 向银泉. All rights reserved.
//

import UIKit

class LoginViewController: UIViewController {

    @IBOutlet weak var coverImageView: UIImageView!
    
    @IBOutlet weak var fontLabelName: UILabel!
    
    @IBOutlet weak var fontLabelPassword: UILabel!
    
    @IBOutlet weak var loginbtn: UIButton!
    @IBOutlet weak var PasswordTextField: UITextField!
    @IBOutlet weak var AccounttextField: UITextField!
    override func viewDidLoad() {
        super.viewDidLoad()
        loginbtn.layer.masksToBounds = true
        loginbtn.layer.cornerRadius = 10
        self.title = "登录"
        // Do any additional setup after loading the view.
    }

    
    
    @IBAction func Loginbutton(sender: AnyObject) {
        KVNProgress.showWithStatus("正在登录")
        toolManager.BmobUserLogin(self.AccounttextField.text!, passWord: self.PasswordTextField.text!) { (ret, message) in
            if ret == true{
                NSUserDefaults.standardUserDefaults().setObject(self.AccounttextField.text!, forKey:UD_CurrentUserName)
                NSUserDefaults.standardUserDefaults().setBool(true, forKey: UD_LoginStatus)
                self.navigationController?.popViewControllerAnimated(true)
                KVNProgress.showSuccessWithStatus(message)
                
            }else{
                KVNProgress.showErrorWithStatus(message)
            }
        }
 
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
